From 63563ab8cd13bf65383a7ad45ac398e790aae9fa Mon Sep 17 00:00:00 2001 From: Shouvik Kar Date: Fri, 17 Jul 2026 18:17:04 +0000 Subject: [PATCH] [PATCH] WidgetsAskUserActionHandler: show the SSL error dialog on the GUI thread askIgnoreSslErrors() can be called from a non-GUI thread (e.g. the weather ion runs its KIO jobs on a worker thread), where it constructed the KMessageDialog off the GUI thread and crashed while painting it. Marshal the dialog onto the GUI thread with QMetaObject::invokeMethod(qGuiApp, ...), like every other handler in this class already does. BUG: 519614 Gbp-Pq: Name upstream_dd40b4c0_WidgetsAskUserActionHandler-show-the-SSL-error-dialog-on-the-GUI-thread.patch --- src/widgets/widgetsaskuseractionhandler.cpp | 42 +++++++++++---------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/widgets/widgetsaskuseractionhandler.cpp b/src/widgets/widgetsaskuseractionhandler.cpp index db8d895..85aedca 100644 --- a/src/widgets/widgetsaskuseractionhandler.cpp +++ b/src/widgets/widgetsaskuseractionhandler.cpp @@ -502,32 +502,34 @@ void KIO::WidgetsAskUserActionHandler::setWindow(QWidget *window) void KIO::WidgetsAskUserActionHandler::askIgnoreSslErrors(const QVariantMap &sslErrorData, QWidget *parent) { - QWidget *parentWidget = d->getParentWidget(parent); + QMetaObject::invokeMethod(qGuiApp, [=, this] { + QWidget *parentWidget = d->getParentWidget(parent); - QString message = i18n("The server failed the authenticity check (%1).\n\n", sslErrorData[QLatin1String("hostname")].toString()); + QString message = i18n("The server failed the authenticity check (%1).\n\n", sslErrorData[QLatin1String("hostname")].toString()); - message += sslErrorData[QLatin1String("sslError")].toString(); + message += sslErrorData[QLatin1String("sslError")].toString(); - auto *dialog = new KMessageDialog(KMessageDialog::WarningTwoActionsCancel, message, parentWidget); + auto *dialog = new KMessageDialog(KMessageDialog::WarningTwoActionsCancel, message, parentWidget); - dialog->setAttribute(Qt::WA_DeleteOnClose); - dialog->setCaption(i18n("Server Authentication")); - dialog->setIcon(QIcon{}); - dialog->setButtons(KGuiItem{i18n("&Details"), QStringLiteral("documentinfo")}, KStandardGuiItem::cont(), KStandardGuiItem::cancel()); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->setCaption(i18n("Server Authentication")); + dialog->setIcon(QIcon{}); + dialog->setButtons(KGuiItem{i18n("&Details"), QStringLiteral("documentinfo")}, KStandardGuiItem::cont(), KStandardGuiItem::cancel()); + + connect(dialog, &KMessageDialog::finished, this, [this, parentWidget, sslErrorData](int result) { + if (result == KMessageDialog::PrimaryAction) { + showSslDetails(sslErrorData, parentWidget); + } else if (result == KMessageDialog::SecondaryAction) { + // continue(); + Q_EMIT askIgnoreSslErrorsResult(1); + } else if (result == KMessageDialog::Cancel) { + // cancel(); + Q_EMIT askIgnoreSslErrorsResult(0); + } + }); - connect(dialog, &KMessageDialog::finished, this, [this, parentWidget, sslErrorData](int result) { - if (result == KMessageDialog::PrimaryAction) { - showSslDetails(sslErrorData, parentWidget); - } else if (result == KMessageDialog::SecondaryAction) { - // continue(); - Q_EMIT askIgnoreSslErrorsResult(1); - } else if (result == KMessageDialog::Cancel) { - // cancel(); - Q_EMIT askIgnoreSslErrorsResult(0); - } + dialog->show(); }); - - dialog->show(); } void KIO::WidgetsAskUserActionHandler::showSslDetails(const QVariantMap &sslErrorData, QWidget *parentWidget) -- 2.39.5